﻿using System;
using System.Data;
using System.Web;
using System.Web.UI.WebControls;
using Texfina.Core.Common;
using Texfina.Core.Web;
using Texfina.Common.Mg;
using Texfina.Core.Data;
using Texfina.Entity.Rh;
using RHBOQry = Texfina.BOQry.Rh;

namespace RH
{
   public partial class wfPersonalPlani : SearchPage
   {
      public const int _GRDLIST_STANULADO = 5;

      protected void Page_Load(object sender, EventArgs e)
      {

         this.LoadInitialSettings();
         if (this.IsPostBack)
         {
            this.LoadInPostBack();
            return;
         }

         this.LoadData();
         SearchData();

      }

      public override void LoadInitialSettings()
      {
         Label lbl = (Label)this.Master.FindControl("lblTitle");
         lbl.Text = "Personal - Planilla";
         this.Page.Form.DefaultButton = bttSearch.UniqueID;
      }

      public override void SearchData()
      {

         EPersonalPlanilla objE = new EPersonalPlanilla();

         objE.IdEmpresa = Session[ConstSessionVar.EMPRESA].ToString();
         objE.IdPlanilla = Request.QueryString["IdPlanilla"];

         if (this.txtidPersonal.Text == "")
            objE.IdPersonal = null;
         else
            objE.IdPersonal = this.txtidPersonal.Text;

         if (this.txtnuDocIden.Text == "")
            objE.NuDocIden = null;
         else
            objE.NuDocIden = this.txtnuDocIden.Text;

         if (this.txtdsPersonal.Text == "")
            objE.DsApellNom = null;
         else
            objE.DsApellNom = this.txtdsPersonal.Text;

         RHBOQry.IPersonal objBO = (RHBOQry.IPersonal)WCFHelper.GetObject<RHBOQry.IPersonal>(typeof(RHBOQry.Personal));
         DataTable dt = objBO.GetPersonalxPlanilla(objE);

         this.GridSetDataBinding(grdList, dt);

      }

      protected void grdList_RowCreated(object sender, GridViewRowEventArgs e)
      {
         if (e.Row.RowType == DataControlRowType.DataRow)
         {
            e.Row.Attributes.Add("ondblclick", "rowDblClick(" + e.Row.RowIndex.ToString() + ")");
         }
      }

      protected void bttOk_Click(object sender, EventArgs e)
      {
         this.SearchData();
      }
   }
}